*Set your directory:
cd xx

//NOTE: As explained in supplementary material, this code randomizes the candidate labeled as the "hawk" in cases where respondents perceive candidates as taking identical positions on defense spending. As a result of that randomization, some coefficients in the paper will not replicate exactly.

use anes_cdf.dta, clear
rename VCF0004 year
rename VCF0009z weight

*adjust weights for sample size
gen weight2=weight

quietly forvalues value=1948(4)2016 {  // This adjusts weights by sample size so that all cohorts exert equal impact on aggregate results
 sum year if year==`value'
 replace weight2=weight2*r(N)/_N*10 if year==`value'
}

quietly forvalues value=1954(4)2014 { // Remove midterms and elections prior to 1980
 drop if year==`value'
}
drop if year<1980

egen yearid=concat(year VCF0006)
sort yearid
save anes_rendered.dta, replace

*Add relevant data not in the cumulative file
use anes_1984.dta, clear
 keep V840004 V840388 V840389 V840390
 gen year=1984
 egen yearid=concat(year V840004)
 sort yearid
 drop V840004
 save anes_1984_pared.dta, replace
 use anes_rendered.dta, clear
  merge 1:1 yearid using anes_1984_pared.dta
  drop _merge
  erase anes_1984_pared.dta
  save anes_rendered.dta, replace
use anes_2004, clear
 keep V040001 V043107 V045126 V045127
 gen year=2004
 egen yearid=concat(year V040001)
 sort yearid
 drop V040001
save anes_2004_pared.dta, replace
use anes_rendered.dta, clear
  merge 1:1 yearid using anes_2004_pared.dta
  drop _merge
  save anes_rendered.dta, replace
  erase anes_2004_pared.dta
use anes_2012, clear
 keep caseid def*
 gen year=2012
 egen yearid=concat(year caseid)
 sort yearid
 save anes_2012_pared.dta, replace
  use anes_rendered.dta, clear
  merge 1:1 yearid using anes_2012_pared.dta
  drop _merge
  save anes_rendered.dta, replace
  erase anes_2012_pared.dta

*Vote
gen vote=cond(VCF0704==1,0,cond(VCF0704==2,1,.))

*Defense spending data
rename VCF0843 ds_preference
 replace ds_preference=defsppr_self if year==2012
  drop defsppr_self
 replace ds_preference=. if ds_preference<1 | ds_preference>7
rename VCF9081 ds_perception_dem
 replace ds_perception_dem=defsppr_dpc if year==2012
 replace ds_perception_dem=. if ds_perception_dem<1 | ds_perception_dem>7
rename VCF9089 ds_perception_rep
 replace ds_perception_rep=defsppr_rpc if year==2012
 replace ds_perception_rep=. if ds_perception_rep<1 | ds_perception_rep>7
  drop defsppr_rpc defsppr_dpc
  
*Demographic controls
gen female=cond(VCF0104==2,1,0)
 drop VCF0104
gen black=cond(VCF0105b==2,1,0)
 drop VCF0105b
rename VCF0301 party
 replace party=. if party==0
  gen democrat=cond(party<3,1,0)
  gen republican=cond(party>5 & party!=.,1,0)
egen party_std=std(party)
rename VCF0803 ideology
 replace ideology=4 if ideology==0 | ideology==9
egen ideology_std=std(ideology)

*Code image variables
foreach x in 50 51 52 53 54 55 56 57 62 63 64 65 66 67 68 69 {
replace VCF03`x'=. if VCF03`x'==-4 | VCF03`x'==-3
}
 gen intelligent=(5-VCF0362)-(5-VCF0350)
 gen compassionate=(5-VCF0363)-(5-VCF0351)
 gen decent=(5-VCF0364)-(5-VCF0352)
 gen inspiring=(5-VCF0365)-(5-VCF0353)
 gen knowledgeable=(5-VCF0366)-(5-VCF0354)
 gen moral=(5-VCF0367)-(5-VCF0355)
 gen strong=(5-VCF0368)-(5-VCF0356)
 gen cares=(5-VCF0369)-(5-VCF0357)

*Code foreign policy position questions (relevant for index of overall hawkishness)
rename VCF0841 ussr_preference
rename VCF9082 ussr_perception_dem
rename VCF9090 ussr_perception_rep

rename V043107 hawk_preference
rename V045127 hawk_perception_dem
rename V045126 hawk_perception_rep

rename V840388 centam_preference
rename V840390 centam_perception_dem
rename V840389 centam_perception_rep
replace centam_preference=8-centam_preference
replace centam_perception_dem=8-centam_perception_dem
replace centam_perception_rep=8-centam_perception_rep

gen fp_ussr=ussr_preference
gen fp_defense_spending=ds_preference
gen fp_hawk=hawk_preference
 replace fp_hawk=VCF0844 if fp_hawk==.
gen fp_centam=centam_preference

*Prune
quietly foreach x in "fp_centam" "fp_ussr" "fp_defense_spending" "fp_hawk"{
replace `x'=. if `x'==8 |`x'==9 | `x'<1 | `x'>7
}

*Preference alignment measures
foreach v in "ds" "ussr" "hawk" "centam"{
 replace `v'_preference=. if `v'_preference<1 | `v'_preference>7
 replace `v'_perception_dem=. if `v'_perception_dem<1 | `v'_perception_dem>7
 replace `v'_perception_rep=. if `v'_perception_rep<1 | `v'_perception_rep>7
gen `v'_align=abs(`v'_perception_dem-`v'_preference)-abs(`v'_perception_rep-`v'_preference)
 egen `v'_align_std=std(`v'_align)
replace `v'_align_std=`v'_align_std
}

gen id=_n

//Code measure of which candidate spends more on defense
gen ds_hawk=0
 replace ds_hawk=. if ds_perception_rep==. | ds_perception_dem==.
 replace ds_hawk=ds_perception_rep-ds_perception_dem if ds_perception_rep>ds_perception_dem
 replace ds_hawk=ds_perception_dem-ds_perception_rep if ds_perception_dem>ds_perception_rep
gen hawk_is_rep=round(uniform()) // randomizes the hawk designation in cases where respondent sees no difference in candidate positions on defense spending
 replace hawk_is_rep=1 if ds_perception_rep>ds_perception_dem
 replace hawk_is_rep=0 if ds_perception_dem>ds_perception_rep
gen ds_equal=cond(ds_hawk==0,1,0)

//Code overall index of hawkishness
gen ds1=ds_perception_rep-ds_perception_dem
gen ussr1=ussr_perception_rep-ussr_perception_dem
gen centam1=centam_perception_rep-centam_perception_dem
gen hawk1=hawk_perception_rep-hawk_perception_dem

egen allhawk_perception2=rmean(ds1 ussr1 hawk1 centam1)
gen allhawk_is_rep=round(uniform())
 replace allhawk_is_rep=1 if allhawk_perception2>0
 replace allhawk_is_rep=0 if allhawk_perception2<0
gen allhawk_perception=allhawk_perception2
replace allhawk_perception=1-allhawk_perception2 if allhawk_is_rep==0
gen hawk_equal=cond(allhawk_perception==0,1,0)

egen allhawk_pref=rmean(ds_pref ussr_pref hawk_pref centam_pref)

egen allhawk_align=rmean(ds_align ussr_align hawk_align centam_align)
replace allhawk_align=(-1)*allhawk_align if allhawk_is_rep==0

//Code data relative to which candidate is seen as the hawk
gen hawk_party=party
 replace hawk_party=8-party if hawk_is_rep==0
gen allhawk_party=party
 replace allhawk_party=8-party if allhawk_is_rep==0

gen hawk_ideology=ideology
 replace hawk_ideology=8-ideology if hawk_is_rep==0
gen allhawk_ideology=ideology
 replace allhawk_ideology=8-ideology if allhawk_is_rep==0
gen hawk_vote=vote
 replace hawk_vote=1-vote if hawk_is_rep==0
gen allhawk_vote=vote
 replace allhawk_vote=1-vote if allhawk_is_rep==0
gen blackxrep=black*hawk_is_rep
gen blackxrep2=black*allhawk_is_rep
gen femalexrep=female*hawk_is_rep
gen femalexrep2=female*allhawk_is_rep
gen ds_align_hawk=ds_align
 replace ds_align_hawk=(-1)*ds_align if hawk_is_rep==0

gen allhawkyear=0
 replace allhawkyear=1 if year==1980 | year==1984 | year==1988 | year==2004

//Recode trait measures
foreach trait in "strong" "inspiring" "decent" "compassionate" "knowledgeable" "moral" "cares" "intelligent" {
gen hawk_`trait'=`trait'
 replace hawk_`trait'=(-1)*`trait' if hawk_is_rep==0
gen allhawk_`trait'=`trait'
 replace allhawk_`trait'=(-1)*`trait' if allhawk_is_rep==0
}

//code incumbency dummy
gen hawk_is_incumbent=0
 replace hawk_is_incumbent=1 if hawk_is_rep==0 & year==1980
 replace hawk_is_incumbent=1 if hawk_is_rep==1 & year==1984
 replace hawk_is_incumbent=1 if hawk_is_rep==1 & year==1992
 replace hawk_is_incumbent=1 if hawk_is_rep==0 & year==1996
 replace hawk_is_incumbent=1 if hawk_is_rep==1 & year==2004
 replace hawk_is_incumbent=1 if hawk_is_rep==0 & year==2012

save anes_preferences.dta,replace

*ANALYZE
use anes_preferences, clear
svyset _n [pweight=weight2]

//Descriptive data on defense spending differential
svy: mean ds_hawk
estat sd // mean 2.3, sd 1.6

//85 percent of respondents perceive a difference in candidate positions on defense spending
svy: mean ds_equal if ds_hawk!=.

//When voters perceive a difference in candidate positions on defense spending, the more hawkish candidate is also perceived as being a stronger leader
svy: reg hawk_strong if ds_hawk>0 & ds_hawk!=. // (+0.34)
svy: mean hawk_strong
 estat sd // sd=1.4

*Figure 1: Defense spending --> perceptions of strength
svy: reg hawk_strong ds_hawk ds_align_hawk hawk_is_rep hawk_is_incumbent hawk_party hawk_ideology female black femalexrep blackxrep ds_equal  i.year
 margins, at(ds_hawk=(0(1)6)) vce(unconditional) post
coefplot, xlabel(1 "0") ylabel(,labsize(medium)) xtitle(" ""Defense Spending Differential", size(medium)) ytitle("Leadership strength"" ",size(medium)) vertical recast(line) ciopts(recast(rarea) color(%90)) xsize(3.5) ysize(3.5) plotregion(lwidth(none)) xlabel(1 "+0" 2 "+1" 3 "+2" 4 "+3" 5 "+4" 6 "+5" 7 "+6", noticks labsize(medsmall))
 graph export fig1.tif, replace

//first difference: coefficient estimate in Figure 1 is 0.051. Sd for hawk_strong is 1.4. 1.4*0.051 = 0.07.

//footnote 36: correlation between inspiring and strong
correl strong inspiring

*Figure 2: Defense spending coefficients
matrix traits=J(8,4,.)
scalar i = 1
foreach trait in "compassionate" "decent" "intelligent" "knowledgeable" "cares" "moral" "strong"{
matrix traits[scalar(i),1]=scalar(i)
svy: reg hawk_`trait' ds_hawk ds_align_hawk hawk_is_rep hawk_is_incumbent hawk_party hawk_ideology female black femalexrep blackxrep ds_equal  i.year
 matrix traits[scalar(i),2]=_b[ds_hawk]
 matrix traits[scalar(i),3]=_b[ds_hawk]+invttail(e(df_r),0.025)*_se[ds_hawk]
 matrix traits[scalar(i),4]=_b[ds_hawk]-invttail(e(df_r),0.025)*_se[ds_hawk]
scalar i = scalar(i)+1
}
svmat traits
rename traits1 index
rename traits2 mean
rename traits3 upper
rename traits4 lower

twoway scatter mean index, msymbol(circle) mcolor(black) msize(medium) || rcap upper lower index, color(black) msize(0) plotregion(lwidth(0)) xsc(titlegap(5)) xlabel(1 "Compassionate" 2 "Decent" 3 "Intelligent" 4 "Knowledgeable" 5 "Cares" 6 "Moral" 7 "Strong Leader", labsize(medsmall) angle(45) noticks) ylabel(, angle(horiz)) ysc(titlegap(5)) ytitle("Defense Spending Coefficient""(with 95% intervals)", size(medium)) leg(off) yline(0, lpattern(dot)) xtitle("Candidate traits", size(medium))
graph export fig2.tif, replace
drop index mean upper lower

//footnote 37
svy: reg hawk_moral ds_hawk ds_align_hawk hawk_is_rep hawk_is_incumbent hawk_party hawk_ideology female black femalexrep blackxrep ds_equal i.year if year!=2004

svy: reg hawk_strong ds_hawk ds_align_hawk hawk_is_rep hawk_is_incumbent hawk_party hawk_ideology female black femalexrep blackxrep ds_equal i.year if year!=2004

*Figure 3: Defense spending --> voting
svy: logit hawk_vote ds_hawk ds_align_hawk hawk_is_rep hawk_is_incumbent hawk_party hawk_ideology female black femalexrep blackxrep ds_equal i.year if hawk_strong!=.
 margins, at(ds_hawk=(0(1)6)) vce(unconditional) post
 coefplot, ysc(range(.48(.2).65)) ylabel(.5 "50%" .55 "55%" .6 "60%" .65 "65%",labsize(medium)) xtitle(" ""Defense Spending Differential", size(medium)) ytitle("Vote Share",size(medium)) vertical recast(line) ciopts(recast(rarea) color(%90)) xsize(3.5) ysize(3.5) plotregion(lwidth(none)) xlabel(1 "+0" 2 "+1" 3 "+2" 4 "+3" 5 "+4" 6 "+5" 7 "+6", noticks labsize(medsmall)) ysc(titlegap(5))
 graph export fig3.tif, replace

svy: logit hawk_vote ds_hawk ds_align_hawk hawk_is_rep hawk_is_incumbent hawk_party hawk_ideology female black femalexrep blackxrep ds_equal i.year if hawk_strong!=.
fitstat
 
*Table 1. Mediation
forvalues i=1980(4)2008{
gen year`i'=cond(year==`i',1,0)
}

//Strong
medeff (regress hawk_strong ds_hawk ds_equal hawk_party hawk_ideology hawk_is_rep  hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1980 year1984 year1988 year1992 year1996 year2000 year2004) (logit hawk_vote ds_hawk ds_equal hawk_strong hawk_party hawk_ideology hawk_is_rep hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1980 year1984 year1988 year1992 year1996 year2000 year2004) [pweight=weight2], med(hawk_strong) treat(ds_hawk) sims(10000)

//Cares
medeff (regress hawk_cares ds_hawk ds_equal hawk_party hawk_ideology hawk_is_re   hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1984 year1988 year1992 year1996 year2000 year2004) (logit hawk_vote ds_hawk ds_equal hawk_cares hawk_party hawk_ideology hawk_is_rep hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1984 year1988 year1992 year1996 year2000 year2004) [pweight=weight2], med(hawk_cares) treat(ds_hawk) sims(10000)

//Moral
medeff (regress hawk_moral ds_hawk ds_equal hawk_party hawk_ideology hawk_is_re   hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1980 year1984 year1988 year1992 year1996 year2000 year2004) (logit hawk_vote ds_hawk ds_equal hawk_moral hawk_party hawk_ideology hawk_is_rep hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1980 year1984 year1988 year1992 year1996 year2000 year2004) [pweight=weight2], med(hawk_moral) treat(ds_hawk) sims(10000)

//Knowledgeable
medeff (regress hawk_knowledgeable ds_hawk ds_equal hawk_party hawk_ideology hawk_is_re hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1980 year1984 year1988 year1992 year1996 year2000 year2004) (logit hawk_vote ds_hawk ds_equal hawk_knowledgeable hawk_party hawk_ideology hawk_is_rep hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1980 year1984 year1988 year1992 year1996 year2000 year2004) [pweight=weight2], med(hawk_knowledgeable) treat(ds_hawk) sims(10000)

//Intelligent
medeff (regress hawk_intelligent ds_hawk ds_equal hawk_party hawk_ideology hawk_is_re hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1984 year1988 year1992 year2000 year2004) (logit hawk_vote ds_hawk ds_equal hawk_intelligent hawk_party hawk_ideology hawk_is_rep hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1984 year1988 year1992 year2000 year2004) [pweight=weight2], med(hawk_intelligent) treat(ds_hawk) sims(10000)

//Compassionate
medeff (regress hawk_compassionate ds_hawk ds_equal hawk_party hawk_ideology hawk_is_re  hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1984 year1988) (logit hawk_vote ds_hawk ds_equal hawk_compassionate hawk_party hawk_ideology hawk_is_rep hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1984 year1988) [pweight=weight2], med(hawk_compassionate) treat(ds_hawk) sims(10000)

//Decent [Have to adjust year fixed effects to avoid nonconformability]
medeff (regress hawk_decent ds_hawk ds_equal hawk_party hawk_ideology hawk_is_re  hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1984) (logit hawk_vote ds_hawk ds_equal hawk_decent hawk_party hawk_ideology hawk_is_rep hawk_is_incumbent female black femalexrep blackxrep ds_align_hawk year1984) [pweight=weight2], med(hawk_decent) treat(ds_hawk) sims(10000)


*SI

*Figure S1: ANES candidate perceptions
matrix perc=J(20,4,.)
forvalues value=1(1)20{
matrix perc[`value',1]=`value'
}
svy: reg ds_perception_rep if year==2004
 matrix perc[1,2]=_b[_cons]
 matrix perc[1,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[1,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_rep if year==1984
 matrix perc[2,2]=_b[_cons]
 matrix perc[2,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[2,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_rep if year==1980
 matrix perc[3,2]=_b[_cons]
 matrix perc[3,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[3,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_rep if year==2008
 matrix perc[4,2]=_b[_cons]
 matrix perc[4,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[4,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_rep if year==2016
 matrix perc[5,2]=_b[_cons]
 matrix perc[5,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[5,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_rep if year==1988
 matrix perc[6,2]=_b[_cons]
 matrix perc[6,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[6,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_rep if year==2000
 matrix perc[7,2]=_b[_cons]
 matrix perc[7,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[7,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_rep if year==2012
 matrix perc[8,2]=_b[_cons]
 matrix perc[8,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[8,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_rep if year==1992
 matrix perc[9,2]=_b[_cons]
 matrix perc[9,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[9,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_rep if year==1996
 matrix perc[10,2]=_b[_cons]
 matrix perc[10,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[10,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_dem if year==2000
 matrix perc[11,2]=_b[_cons]
 matrix perc[11,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[11,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_dem if year==1996
 matrix perc[12,2]=_b[_cons]
 matrix perc[12,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[12,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_dem if year==1980
 matrix perc[13,2]=_b[_cons]
 matrix perc[13,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[13,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_dem if year==2016
 matrix perc[14,2]=_b[_cons]
 matrix perc[14,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[14,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_dem if year==2004
 matrix perc[15,2]=_b[_cons]
 matrix perc[15,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[15,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_dem if year==2012
 matrix perc[16,2]=_b[_cons]
 matrix perc[16,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[16,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_dem if year==2008
 matrix perc[17,2]=_b[_cons]
 matrix perc[17,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[17,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_dem if year==1984
 matrix perc[18,2]=_b[_cons]
 matrix perc[18,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[18,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_dem if year==1992
 matrix perc[19,2]=_b[_cons]
 matrix perc[19,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[19,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]
svy: reg ds_perception_dem if year==1988
 matrix perc[20,2]=_b[_cons]
 matrix perc[20,3]=_b[_cons]+invttail(e(df_r),0.025)*_se[_cons]
 matrix perc[20,4]=_b[_cons]-invttail(e(df_r),0.025)*_se[_cons]

svmat perc
rename perc1 index
 replace index =21-index
rename perc2 mean
rename perc3 upper
rename perc lower
 
twoway scatter index mean, mcolor(black) msize(medium) || rcap upper lower index, horizontal msize(0) lwidth(thick) color(black) ylabel(20 "George W. Bush (2004)" 19 "Ronald Reagan (1984)" 18 "Ronald Reagan (1980)" 17 "John McCain (2008)" 16 "Donald Trump (2016)" 15 "George H. W. Bush (1988)" 14 "George W. Bush (2000)" 13 "Mitt Romney (2012)" 12 "George H. W. Bush (1992)" 11 "Bob Dole (1996)"  10 "Al Gore (2000)" 9 "Bill Clinton (1996)" 8 "Jimmy Carter (1980)" 7 "Hillary Clinton (2016)" 6 "John Kerry (2004)" 5 "Barack Obama (2012)" 4 "Barack Obama (2008)" 3 "Walter Mondale (1984)" 2 "Bill Clinton (1992)" 1 "Michael Dukakis (1988)", labsize(medsmall) angle(horiz)) plotregion(lwidth(0)) ytitle("") xtitle("") leg(off) xlabel(1 `""1"" ""Greatly""decrease""' 2 "2" 3 "3" 4 `""4"" ""No""change""' 5 "5" 6 "6" 7 `""7"" ""Greatly""increase""', noticks labsize(mlarge)) xline(4, lpattern(dot)) graphregion(margin(r+5))
graph export figS1.tif, replace
drop index mean upper lower


*Fig S2
//Translate data into one observation per candidate so that we can draw conclusions about absolute values
gen candxdem=1
gen candxrep=1
drop id
gen id=_n
reshape long candx, i(id) j(cparty, string)

gen party2=party
 replace party2=8-party if cparty=="dem"
gen ideology2=ideology
 replace ideology2=8-ideology if cparty=="dem"

gen ds_align2=abs(ds_perception_rep-ds_preference)
 replace ds_align2=abs(ds_perception_dem-ds_preference) if cparty=="dem"
gen ds_align2_other=abs(ds_perception_rep-ds_preference)
 replace ds_align2_other=abs(ds_perception_dem-ds_preference) if cparty=="rep"
 
gen ds_perception=ds_perception_rep
 replace ds_perception=ds_perception_dem if cparty=="dem"
gen ds_perception_other=ds_perception_rep
 replace ds_perception_other=ds_perception_dem if cparty=="rep"
 
gen democratic_candidate=0
 replace democratic_candidate=1 if cparty=="dem"

 
*Candidate effects
gen cand_reagan=cond(year==1980 & cparty=="rep",1,0)
gen cand_carter=cond(year==1980 & cparty=="dem",1,0)
gen cand_mondale=cond(year==1984 & cparty=="dem",1,0)
 replace cand_reagan=1 if year==1984 & cparty=="rep"
gen cand_dukakis=cond(year==1988 & cparty=="dem",1,0)
gen cand_bush41=cond(year==1988 & cparty=="rep",1,0)
gen cand_wjc=cond(year==1992 & cparty=="dem",1,0)
 replace cand_bush41=1 if year==1992 & cparty=="rep"
 replace cand_wjc=1 if year==1996 & cparty=="dem"
gen cand_dole=cond(year==1996 & cparty=="rep",1,0)
gen cand_gore=cond(year==2000 & cparty=="dem",1,0)
gen cand_bush43=cond(year==2000 & cparty=="rep",1,0)
gen cand_kerry=cond(year==2004 & cparty=="dem",1,0)
 replace cand_bush43=1 if year==2004 & cparty=="rep"
gen cand_obama=cond(year==2008 & cparty=="dem",1,0)
gen cand_mccain=cond(year==2008 & cparty=="rep",1,0)
 replace cand_obama=1 if year==2008 & cparty=="dem"
gen cand_romney=cond(year==2012 & cparty=="rep",1,0)
gen cand_hrc=cond(year==2016 & cparty=="dem",1,0)
gen cand_trump=cond(year==2016 & cparty=="rep",1,0)

*Code demographic interactions
gen blackxdem=black*democratic_candidate
gen femalexdem=female*democratic_candidate
 
*Code image variables
gen strong_c=5-VCF0368
 replace strong_c=5-VCF0356 if cparty=="dem"
  gen strong_c_other=5-VCF0368
   replace strong_c_other=5-VCF0356 if cparty=="rep"

svyset _n [pweight=weight2]

svy: reg strong_c i.ds_perception ds_equal ds_align2 ds_align2_other democratic_candidate female femalexdem black blackxdem party2 ideology2 ds_perception_other strong_c_other cand_*
 margins ds_perception, post
 marginsplot, plotregion(lwidth(0)) plot1opts(lwidth(0)) ciopts(msize(0) lcolor(black))  plotopts(msymbol(circle) mcolor(black)) leg(off)  title("(b)""Individual candidate ratings"" ", size(medium)) ylabel(2.4 "2.4" 2.6 "2.6" 2.8 "2.8", labsize(medsmall)) ytitle("Leadership strength"" ", size(medium)) xtitle("Candidate Position on Defense Spending", size(medium)) xlabel(1 `""1"" ""Greatly""decrease""' 2 "2" 3 "3" 4 `""4"" ""No""change""' 5 "5" 6 "6" 7 `""7"" ""Greatly""increase""', noticks labsize(medsmall)) xsc(range(0.8 7.1) titlegap(5)) leg(off) xsize(3.5) ysize(3.5)
 graph export figS2.tif, replace


*Figure S3a: Allhawk --> perceptions of strength
use anes_preferences, clear
svyset _n [pweight=weight2]
svy: reg allhawk_strong allhawk_perception hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align i.year
 margins, at(allhawk_perception=(0(1)6)) vce(unconditional) post
 coefplot, ylabel(,labsize(medium)) title("(a)""Hawkishness and leadership strength"" ", size(medium)) xtitle(" ""Hawkishness Differential", size(medium)) ytitle("Leadership strength",size(medium)) vertical recast(line) ciopts(recast(rarea) color(%90)) xsize(3.5) ysize(3.5) plotregion(lwidth(none)) xlabel(1 "+0" 2 "+1" 3 "+2" 4 "+3" 5 "+4" 6 "+5" 7 "+6", noticks labsize(medsmall)) ysc(titlegap(5))
 graph export figS3a.tif, replace
 
*Figure S3b: Placebo w/allhawk
matrix traits=J(8,4,.)
scalar i = 1
foreach trait in "compassionate" "decent" "intelligent" "knowledgeable" "cares" "moral" "strong"{
matrix traits[scalar(i),1]=scalar(i)
svy: reg allhawk_`trait' allhawk_perception allhawk_party hawk_equal allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align i.year
 matrix traits[scalar(i),2]=_b[allhawk_perception]
 matrix traits[scalar(i),3]=_b[allhawk_perception]+invttail(e(df_r),0.025)*_se[allhawk_perception]
 matrix traits[scalar(i),4]=_b[allhawk_perception]-invttail(e(df_r),0.025)*_se[allhawk_perception]
scalar i = scalar(i)+1
}
svmat traits
rename traits1 index
rename traits2 mean
rename traits3 upper
rename traits4 lower

twoway scatter mean index, title("(b)""Hawkishness and candidate traits"" ",size(medium)) xsize(3.5) ysize(3.5) msymbol(circle) mcolor(black) msize(medium) || rcap upper lower index, color(black) msize(0) plotregion(lwidth(0)) xsc(titlegap(5)) xlabel(1 "Compassionate" 2 "Decent" 3 "Intelligent" 4 "Knowledgeable" 5 "Cares" 6 "Moral" 7 "Strong Leader", labsize(medsmall) angle(45) noticks) ylabel(, angle(horiz)) ytitle("Hawkishness Coefficient""(with 95% intervals)", size(medium)) leg(off) yline(0, lpattern(dot)) xtitle(" ")
graph export figS3b.tif, replace
drop index mean upper lower

*Figure S3c: Allhawk --> voting
svy: logit allhawk_vote allhawk_perception hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align i.year if allhawk_strong!=.
 margins, at(allhawk_perception=(0(1)6)) vce(unconditional) post
 coefplot, ylabel(.5 "50%" .55 "55%" .6 "60%" .65 "65%",labsize(medium)) title("(c)""Hawkishness and vote share"" ", size(medium)) xtitle(" ""Hawkishness Differential", size(medium)) ytitle("Vote Share",size(medium)) vertical recast(line) ciopts(recast(rarea) color(%90)) xsize(3.5) ysize(3.5) plotregion(lwidth(none)) xlabel(1 "+0" 2 "+1" 3 "+2" 4 "+3" 5 "+4" 6 "+5" 7 "+6", noticks labsize(medsmall)) ysc(titlegap(5))
 graph export figS3c.tif, replace

*Table S2
forvalues i=1980(4)2008{
gen year`i'=cond(year==`i',1,0)
}

//Strong
medeff (regress allhawk_strong allhawk_perception hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1980 year1984 year1988 year1992 year1996 year2000 year2004) (logit allhawk_vote allhawk_perception allhawk_strong hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1980 year1984 year1988 year1992 year1996 year2000 year2004) [pweight=weight2], med(allhawk_strong) treat(allhawk_perception) sims(10000)

//Decent [Have to adjust year fixed effects to avoid nonconformability]
medeff (regress allhawk_decent allhawk_perception hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1984) (logit allhawk_vote allhawk_perception allhawk_decent hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1984) [pweight=weight2], med(allhawk_decent) treat(allhawk_perception) sims(10000)

//Moral
medeff (regress allhawk_moral allhawk_perception hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1980 year1984 year1988 year1992 year1996 year2000 year2004) (logit allhawk_vote allhawk_perception allhawk_moral hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1980 year1984 year1988 year1992 year1996 year2000 year2004) [pweight=weight2], med(allhawk_moral) treat(allhawk_perception) sims(10000)

//Cares
medeff (regress allhawk_cares allhawk_perception hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1984 year1988 year1992 year1996 year2000 year2004) (logit allhawk_vote allhawk_perception allhawk_cares hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1984 year1988 year1992 year1996 year2000 year2004) [pweight=weight2], med(allhawk_cares) treat(allhawk_perception) sims(10000)

//Compassionate
medeff (regress allhawk_compassionate allhawk_perception hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1984 year1988) (logit allhawk_vote allhawk_perception allhawk_compassionate hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1984 year1988) [pweight=weight2], med(allhawk_compassionate) treat(allhawk_perception) sims(10000)

//Intelligent
medeff (regress allhawk_intelligent allhawk_perception hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1984 year1988 year1992 year2000 year2004) (logit allhawk_vote allhawk_perception allhawk_intelligent hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1984 year1988 year1992 year2000 year2004) [pweight=weight2], med(allhawk_intelligent) treat(allhawk_perception) sims(10000)

//Knowledgeable
medeff (regress allhawk_knowledgeable allhawk_perception hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1980 year1984 year1988 year1992 year1996 year2000 year2004) (logit allhawk_vote allhawk_perception allhawk_knowledgeable hawk_equal allhawk_party allhawk_ideology allhawk_is_rep female black femalexrep2 blackxrep2 allhawk_align year1980 year1984 year1988 year1992 year1996 year2000 year2004) [pweight=weight2], med(allhawk_knowledgeable) treat(allhawk_perception) sims(10000)


